package kku.cs.fgl.actor;

import kku.cs.fgl.Actor;
import kku.cs.fgl.GamePane;
import kku.cs.fgl.Scene;

import org.newdawn.slick.Color;
import org.newdawn.slick.Font;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.geom.Rectangle;

public class LabelActor extends Actor {
    private Font font;
    private String text;
    private boolean changed=true;
    private int baseline=0;
	public LabelActor(float x, float y, String text) {
		super(x,y,20,20,0,0);
		this.text=text;
		font = GamePane.getFont(0);	
	}
	public LabelActor(float x, float y, String text,int fontId) {
		super(x,y,20,20,0,0);
		this.text=text;
		font = GamePane.getFont(fontId);	
	}
	
	public void paint(Graphics g) {
		if(changed){
			float h = font.getHeight(text);
			float w = font.getWidth(text);
			setSize(w+1,h+1);
		}
		//super.paint(g);
		if(font!=null) font.drawString(1,1,text,getFilter());
	}
	public Font getFont() {
		return font;
	}
	public void setFont(Font font) {
		changed=true;
		this.font = font;
	}
	public void setFont(int font) {
		changed=true;
		this.font = GamePane.getFont(font);
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		changed=true;
		this.text = text;
	}   
   
}
